import logging
import sys

if __name__ == '__main__':
    format = '%(asctime)s - %(funcName)s - %(levelname)s - %(message)s' #生成日期
    date_format = '%Y-%m-%d %H:%M:%S'  #调整时间戳

    #日志存放文件
    file_handler = logging.FileHandler('day01.log')
    stream_handler = logging.StreamHandler(sys.stdout)#控制台显示
    stream_handler.setLevel(logging.INFO)#设置控制台日志级别

    logging.basicConfig(  #日志存储到文件中设置
        level=logging.DEBUG, #调整日志级别
        format=format,
        datefmt=date_format, #调整时间戳
        handlers=[file_handler, stream_handler]  #日志输出控制台
                        )

    logging.debug('hello world')
    logging.info('hello world')
    logging.warning('hello world')
    logging.error('hello world')
    logging.critical('hello world')
    print('hello world')